package io;

import java.io.*;

public class Demo10 {
    public static void main(String[] args) {
        try (OutputStream outputStream = new FileOutputStream("d:/test.txt")) {
            // 这就相当于把字节流转成字符流了.
            PrintWriter writer = new PrintWriter(outputStream);
            writer.println("hello");
            writer.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void main1(String[] args) {
        try(OutputStream outputStream = new FileOutputStream("D:/test.txt",true)) {
            PrintWriter writer = new PrintWriter(outputStream);
            writer.print("一个一个梦");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
